/*
 * @Description: 档案处置相关接口
 * @Author: Rfan
 * @Date: 2022-08-08 10:12:14
 * @LastEditTime: 2022-08-08 10:13:19
 */

import request from '@/utils/request';
import type { Key } from 'react';
import type { IPageQuery } from '@/interfaces/global';

/**
 * @description: 待鉴定相关接口
 */
// 查询列表参数类型
export interface IDispositionPendingParams {
  appraisalOpinion?: string;
  appraisalResultJson?: string;
  appraisalType?: number;
  archiveNo?: string;
  archiveTypeId?: number;
  atCode: number;
  atLevel: number;
  atName?: string;
  atType: number;
  createTime?: string;
  dataSources?: number;
  entryId?: number;
  fondName?: string;
  id?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
  status?: number;
  title?: string;
}

// 分页查询待处置列表
export function fetchPendingListByPage(data: IPageQuery<IDispositionPendingParams>) {
  return request({
    url: `/disposal-pending-archive/page`,
    method: 'post',
    data
  });
}

// 添加待处置参数类型
export interface IAddPendingDispositionParams {
  archiveTypeId: number;
  dataSources: number;
  entryId: number;
}

// 添加待处置
export function addPendingDisposition(data: IAddPendingDispositionParams) {
  return request({
    url: `/disposal-pending-archive/`,
    method: 'post',
    data
  });
}

// 删除待处置
export function deletePendingDisposition(id: Key) {
  return request({
    url: `/disposal-pending-archive/${id}`,
    method: 'delete'
  });
}

// 根据批次ID查询待处置列表
export function fetchPendingListByBatch(batchId: Key) {
  return request({
    url: `disposal-pending-archive/list/by-batch-id/${batchId}`,
    method: 'get'
  });
}

// ----------------------------------------------------------------
/**
 * @description: 待处置批次相关接口
 */
// 查询列表参数类型
export interface IDispositionPendingBatchParams {
  id?: number;
  appraiserList: AppraiserList[];
  archiveTypeId: number;
  attachmentList: any[];
  batchName: string;
  remark: string;
}

export interface AppraiserList {
  mobile: string;
  name: string;
  remark: string;
}

export type addBatchDialogParams = Pick<
  IDispositionPendingBatchParams,
  'batchName' | 'archiveTypeId' | 'remark'
>;

// 查询批次列表响应类型
export interface IBatchItemResponse {
  batchName: string;
  batchNo: null;
  atCode: number;
  remark: string;
  fondName: string;
  operatorName: string;
  operator: number;
  atName: string;
  attachmentList: any[];
  createTime: number;
  operatorTime: number;
  report: null;
  archiveTypeId: number;
  id: number;
  atLevel: number;
  atType: number;
  appraiserList: any[];
}

// 查询待处置批次列表
export function fetchPendingBatchList(data: Partial<IDispositionPendingBatchParams>) {
  return request({
    url: `/disposal-pending-archive-batch/list`,
    method: 'post',
    data
  });
}

// 分页查询待处置批次列表
export function fetchPendingBatchListByPage(
  data: IPageQuery<Partial<IDispositionPendingBatchParams>>
) {
  return request({
    url: `/disposal-pending-archive-batch/page`,
    method: 'post',
    data
  });
}

// 新增待处置批次
export function addPendingBatch(data: addBatchDialogParams) {
  return request({
    url: `/disposal-pending-archive-batch/`,
    method: 'post',
    data
  });
}

// 编辑待处置批次
export function editPendingBatch(data: Partial<IDispositionPendingBatchParams>) {
  return request({
    url: `/disposal-pending-archive-batch/`,
    method: 'put',
    data
  });
}

// 删除待处置批次
export function deletePendingDispositionBatch(id: Key) {
  return request({
    url: `/disposal-pending-archive-batch/${id}`,
    method: 'delete'
  });
}

// ----------------------------------------------------------------
/**
 * @description: 待处置档案审批申请单相关接口
 */
// 增加审核单参数类型
export interface IAddDispositionParams {
  applyFormType: number;
  applyTime?: string;
  archiveTypeId: number;
  description: string;
  id?: number;
  status?: number;
  title: string;
}

// 增加鉴定审核
export function addDispositionAudit(data: IAddDispositionParams) {
  return request({
    url: `/disposal-apply-form/`,
    method: 'post',
    data
  });
}

// 编辑审核单参数类型
export interface IEditDispositionParams extends IAddDispositionParams {
  id: number;
}

// 编辑鉴定审核
export function editDispositionAudit(data: IEditDispositionParams) {
  return request({
    url: `/disposal-apply-form/`,
    method: 'put',
    data
  });
}

// 查询列表参数类型
export interface IDispositionListParams extends IAddDispositionParams {
  applyFormNo?: string;
  atName?: string;
  endTime?: string;
  fondName?: string;
  processInstanceId?: string;
  proposer?: string;
  userId?: number;
}
// 查询列表返回类型
export interface IDispositionItemResponse {
  batchNo: number;
  atCode: number;
  fondName: string;
  operatorName: string;
  operator: number;
  atName: string;
  createTime: number;
  operatorTime: number;
  report: null;
  archiveTypeId: number;
  id: number;
  atLevel: number;
  atType: number;
}

// 分页查询鉴定审核列表
export function fetchDispositionListByPage(data: IPageQuery<Partial<IDispositionListParams>>) {
  return request({
    url: `/disposal-apply-form/page`,
    method: 'post',
    data
  });
}

// 删除审核
export function deleteDispositionAudit(id: Key) {
  return request({
    url: `/disposal-apply-form/${id}`,
    method: 'delete'
  });
}

// ----------------------------------------------------------------
/**
 * @description: 档案与批次关系相关接口
 */
export interface IDispositionArchiveBatchParams {
  disposalArchiveIdList: number[];
  disposalBatchId: number;
  disposalBatchNo: string;
}

// 增加鉴定审核
export function addDispositionArchiveBatch(data: IDispositionArchiveBatchParams) {
  return request({
    url: `/disposal-archive-batch/`,
    method: 'post',
    data
  });
}
